/**
 * FileName: DataBindingAdapter
 * Author: Administrator
 * Date: 2020/12/10 0010 14:03
 * Description:
 */
package com.clark.dingding.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.clark.dingding.model.RouterModelData
import com.clark.dingding.interfaces.RouterItemClickCallBack
import com.linkage.linkedlife.R
import com.linkage.linkedlife.databinding.ItemLayoutRouterNextBinding

/**
 * @ClassName: DataBindingAdapter
 * @Description:   这是官方demo给出的databinding的使用方法
 *  @Author: Clark
 * @Date: 2020/12/10 0010 14:03
 */
class DataBindingAdapter :
    BaseQuickAdapter<RouterModelData, BaseDataBindingHolder<ItemLayoutRouterNextBinding>>(R.layout.item_layout_router_next) {
    /**
     * 当 ViewHolder 创建完毕以后，会执行此回调
     * 可以在这里做任何你想做的事情
     */
    override fun convert(
        helper: BaseDataBindingHolder<ItemLayoutRouterNextBinding>,
        item: RouterModelData
    ) {
        val binding = helper.dataBinding
        if (binding != null) {
            // 设置数据
            binding.routerModel2=item
            binding.callback2 = object : RouterItemClickCallBack {
                override fun onClick(dataRouter: RouterModelData) {

                }
            }
            binding.executePendingBindings()
        }
    }

}